package main.util;




import java.io.UnsupportedEncodingException;  
  
/** 
 * 取得给定汉字串的首字母串,即声母串 
 * Title: ChineseCharToEn 
 * @date 2004-02-19 注：只支持GB2312字符集中的汉字 
 */  
public final class PYUtil {  
    private final static int[] li_SecPosValue = { 1601, 1637, 1833, 2078, 2274,  
            2302, 2433, 2594, 2787, 3106, 3212, 3472, 3635, 3722, 3730, 3858,  
            4027, 4086, 4390, 4558, 4684, 4925, 5249, 5590 };  
    private final static String[] lc_FirstLetter = { "a", "b", "c", "d", "e",  
            "f", "g", "h", "j", "k", "l", "m", "n", "o", "p", "q", "r", "s",  
            "t", "w", "x", "y", "z" };  
  
    /** 
     * 取得给定汉字串的首字母串,即声母串 
     * @param str 给定汉字串 
     * @return 声母串 
     */  
    public static String getAllFirstLetter(String str) {  
        if (str == null || str.trim().length() == 0) {  
            return "";  
        }  
  
        String _str = "";  
        for (int i = 0; i < str.length(); i++) {  
            _str = _str + getFirstLetter(str.substring(i, i + 1));  
        }  
  
        return _str;  
    }  
  
    /** 
     * 取得给定汉字的首字母,即声母 
     * @param chinese 给定的汉字 
     * @return 给定汉字的声母 
     */  
    public static String getFirstLetter(String chinese) {  
        if (chinese == null || chinese.trim().length() == 0) {  
            return "";  
        }  
        chinese = conversionStr(chinese, "GB2312", "ISO8859-1");  
  
        if (chinese.length() > 1) // 判断是不是汉字  
        {  
            int li_SectorCode = (int) chinese.charAt(0); // 汉字区码  
            int li_PositionCode = (int) chinese.charAt(1); // 汉字位码  
            li_SectorCode = li_SectorCode - 160;  
            li_PositionCode = li_PositionCode - 160;  
            int li_SecPosCode = li_SectorCode * 100 + li_PositionCode; // 汉字区位码  
            if (li_SecPosCode > 1600 && li_SecPosCode < 5590) {  
                for (int i = 0; i < 23; i++) {  
                    if (li_SecPosCode >= li_SecPosValue[i]  
                            && li_SecPosCode < li_SecPosValue[i + 1]) {  
                        chinese = lc_FirstLetter[i];  
                        break;  
                    }  
                }  
            } else // 非汉字字符,如图形符号或ASCII码  
            {  
                chinese = conversionStr(chinese, "ISO8859-1", "GB2312");  
                chinese = chinese.substring(0, 1);  
            }  
        }  
  
        return chinese;  
    }  
  
    /** 
     * 字符串编码转换 
     * @param str 要转换编码的字符串 
     * @param charsetName 原来的编码 
     * @param toCharsetName 转换后的编码 
     * @return 经过编码转换后的字符串 
     */  
    private static String conversionStr(String str, String charsetName,String toCharsetName) {  
        try {  
            str = new String(str.getBytes(charsetName), toCharsetName);  
        } catch (UnsupportedEncodingException ex) {  
            System.out.println("字符串编码转换异常：" + ex.getMessage());  
        }  
        return str;  
    }  
  
    public static void main(String[] args) {  
    	String []a ={"CTI资源管理",
    			"IVR外呼管理" 				,
    			"O2O订单列表" 				,
    			"test" 						,
    			"test新增0101" 				,
    			"一级客服任务查询" 			,
    			"三方通话" 					,
    			"专区管理" 					,
    			"业务日志查询" 				,
    			"业务日志管理" 				,
    			"业务树维护" 				,
    			"业务类型管理" 				,
    			"个人密码修改" 				,
    			"个人类别配置" 				,
    			"中奖名单" 					,
    			"中奖名单查询" 				,
    			"中奖名单查询" 				,
    			"中奖短信发送" 				,
    			"中奖短信发送" 				,
    			"二次拨号" 					,
    			"互联网" 					,
    			"互联网办理" 				,
    			"互联网查询" 				,
    			"产品维护" 					,
    			"人员信息维护" 				,
    			"人员管理" 					,
    			"今日下单量" 				,
    			"任务管理" 					,
    			"任务管理" 					,
    			"休息" 						,
    			"休眠区" 					,
    			"便签管理" 					,
    			"便签管理" 					,
    			"停止三方通话" 				,
    			"充值缴费记录查询" 			,
    			"兑换码导入" 				,
    			"全部订单查询" 				,
    			"公告便笺" 					,
    			"公告列表" 					,
    			"公告管理" 					,
    			"公告管理及维护" 			,
    			"公告类别管理" 				,
    			"其它配置" 					,
    			"典型案例查询" 				,
    			"养卡黑卡活动客户" 			,
    			"分类标签管理" 				,
    			"功能权限维护" 				,
    			"单日聚力情况" 				,
    			"单点登录测试" 				,
    			"历史问题订单" 				,
    			"历史预约订单" 				,
    			"参数分组管理" 				,
    			"参数模板管理" 				,
    			"发布商品" 					,
    			"取消求助" 					,
    			"受理请求" 					,
    			"受理请求" 					,
    			"受理请求及查询" 			,
    			"合同对账单列表" 			,
    			"合约管理" 					,
    			"员工个人配置" 				,
    			"员工工号查询" 				,
    			"呼出" 						,
    			"品牌信息管理" 				,
    			"商品上下架" 				,
    			"商品审核" 					,
    			"商品查询" 					,
    			"商品管理" 					,
    			"商家信息管理" 				,
    			"商户列表" 					,
    			"商户注册审核" 				,
    			"图片库维护" 				,
    			"在线用户列表" 				,
    			"复核列表" 					,
    			"外呼" 						,
    			"外部求助" 					,
    			"多媒体" 					,
    			"多媒体配置" 				,
    			"多租户" 					,
    			"奖品数量查询" 				,
    			"审批完成" 					,
    			"审批完成" 					,
    			"客户信息" 					,
    			"客户接触" 					,
    			"客户接触管理" 				,
    			"客户标签库维护" 			,
    			"密码验证" 					,
    			"屏蔽用户维护" 				,
    			"工作流" 					,
    			"工作组维护" 				,
    			"工单时限状态配置" 			,
    			"工单时限要素配置" 			,
    			"工单时限规则配置" 			,
    			"工单查询及处理" 			,
    			"工单池" 					,
    			"工单综合查询" 				,
    			"已兑奖名单" 				,
    			"常用功能" 					,
    			"常用操作" 					,
    			"平台维护" 					,
    			"库存管理" 					,
    			"库存预警" 					,
    			"店铺列表" 					,
    			"座席设置" 					,
    			"开始静音" 					,
    			"异动查询" 					,
    			"异常日志查询" 				,
    			"当前业务系统接触查询" 		,
    			"录放音" 					,
    			"待办区" 					,
    			"待归档工单" 				,
    			"微商城管理" 				,
    			"微商城账号管理" 			,
    			"快捷回复设置" 				,
    			"快捷按钮配置" 				,
    			"技能队列关联地市管理" 		,
    			"技能队列关联地市管理" 		,
    			"投诉工单查询" 				,
    			"投诉工单池" 				,
    			"投诉待办" 					,
    			"报文日志查询" 				,
    			"抽取策略模板" 				,
    			"挂机释放" 					,
    			"按照角色配置" 				,
    			"接续日志查询" 				,
    			"接续状态控制" 				,
    			"接续管理" 					,
    			"接触查询" 					,
    			"接触管理" 					,
    			"接触记录" 					,
    			"收藏夹" 					,
    			"收藏夹" 					,
    			"敏感客户名单" 				,
    			"数据字典维护" 				,
    			"数据权限维护" 				,
    			"整理" 						,
    			"整理态" 					,
    			"整理态延长" 				,
    			"无铃" 						,
    			"无铃" 						,
    			"日程列表" 					,
    			"更新全局缓存" 				,
    			"最大会话数设置" 			,
    			"有铃" 						,
    			"有铃" 						,
    			"服务请求查询" 				,
    			"服务请求类型维护" 			,
    			"服务请求配置" 				,
    			"未完服务请求查询" 			,
    			"权限管理" 					,
    			"来电原因维护" 				,
    			"来话应答" 					,
    			"模块列表维护" 				,
    			"测试二级菜单" 				,
    			"渠道入口维护" 				,
    			"特殊客户维护" 				,
    			"申诉工单处理" 				,
    			"申请签出" 					,
    			"留言" 						,
    			"登录日志查询" 				,
    			"监控参数配置" 				,
    			"知识库" 					,
    			"知识库" 					,
    			"短信发送" 					,
    			"短信模板" 					,
    			"砸金蛋日查询" 				,
    			"砸金蛋日查询" 				,
    			"示忙" 						,
    			"示忙" 						,
    			"示闲" 						,
    			"租户信息管理" 				,
    			"空闲" 						,
    			"签入" 						,
    			"签入" 						,
    			"签出" 						,
    			"类目管理" 					,
    			"系统列表维护" 				,
    			"系统参数维护" 				,
    			"系统管理" 					,
    			"系统维护" 					,
    			"线下名单导入" 				,
    			"组织机构维护" 				,
    			"组织管理" 					,
    			"结束休息" 					,
    			"结束会话" 					,
    			"结束静音" 					,
    			"结算出账单列表" 			,
    			"结算申请" 					,
    			"统一配置台" 				,
    			"综合接续" 					,
    			"综合接续" 					,
    			"考评异动查询" 				,
    			"联想预约砸蛋" 				,
    			"联系人管理" 				,
    			"联系人管理" 				,
    			"聚力单日查询" 				,
    			"聚力活动" 					,
    			"聚力活动" 					,
    			"自答" 						,
    			"获取保持" 					,
    			"菜单项维护" 				,
    			"角色类别配置" 				,
    			"角色维护" 					,
    			"解除账号锁定" 				,
    			"计算器" 					,
    			"订单处理" 					,
    			"订单状态总览" 				,
    			"订单管理" 					,
    			"订单管理" 					,
    			"订单订阅监控" 				,
    			"订单预处理" 				,
    			"记事本" 					,
    			"评分模板" 					,
    			"评分类型" 					,
    			"评分项" 					,
    			"话务员接触记录" 			,
    			"语音呼叫操作" 				,
    			"请求来话" 					,
    			"调拨日志" 					,
    			"调账申请" 					,
    			"账号关联业务" 				,
    			"账号关联业务" 				,
    			"质检结果查询" 				,
    			"质检计划执行" 				,
    			"质检计划执行情况" 			,
    			"质检计划管理" 				,
    			"超时订单" 					,
    			"转出" 						,
    			"转接日志查询" 				,
    			"进入整理态" 				,
    			"退出" 						,
    			"通知信息查询" 				,
    			"通话保持" 					,
    			"通话保持" 					,
    			"配置项维护" 				,
    			"重设技能" 					,
    			"锁定" 						,
    			"问卷列表" 					,
    			"问题列表" 					,
    			"阿斯蒂芬" 					,
    			"限时限量抢购" 				,
    			"限购机制" 					,
    			"静音" 						,
    			"预付款余额监控" 			,
    			"预约列表" 					,
    			"预约订单" 					,
    			"频次设置" 					};
    	PYUtil cte = new PYUtil();  
    	for (int i = 0; i < a.length; i++) {
    		 System.out.println( cte.getAllFirstLetter(a[i]));  
		}
       
    }  
  
}  